
<?php $this->JQuery()->javascriptCaptureStart() ?>
$j(document).ready(function() {
	if($j('#section option:selected') == 'Homepage'){
		alert('aa');
	}
    $j('#section').change(function() {
    	if($j('#section').val != ''){
	        jQuery.post(
		        '/admin/todayspick/get-value',
		        {data:$j('#section').val()},
		        function (data) {
		        	var i = 0;
		        	$j.each(data.tp, function() {
						$j('#ls' + i).val(this);
						i++;
					});
		        }
		    );    
		    return false;
		}
    });
});
<?php $this->JQuery()->javascriptCaptureEnd() ?>

<?php $this->headStyle()->captureStart()?>
	.wrap td { border:1px solid #000;}
	tr {padding-top: 5px;}
	.listing_id { width: 300px;}
<?php $this->headStyle()->captureEnd()?>

<form method="POST">
	<label>Section </label>
	<select name="section" id="section">
	<option>Select Section</option>
	<?php 
		foreach($this->sections as $k => $section){
	?>
		<option value="<?php echo (string)$section->_id?>" <?php if(isset($_POST['section']) && $_POST['section'] == (string)$section->_id){ echo 'selected="selected"'; }?>><?php echo (string)$section->name?></option>
	<?php
		}
	?>
	</select> <br />
<table>	
	<th>
		<td colspan="2">Paste the ad id (e.g. 4dfee2819ad3e56dd6ada01a)</td>
	</th>
<?php for($i = 0; $i < 20; $i++):?>
	<tr>
		<td>
			<label>Lisiting <?php echo $i+1?></label>&nbsp;
		</td>
		<td>
			<input type="text" name="ls<?php echo $i?>" id="ls<?php echo $i?>" class="listing_id" <?php if(isset($_POST['ls'.$i])){ echo 'value="'.$_POST['ls'.$i].'"'; }?>>
		</td>
	</tr>
<?php endfor;?>
</table>
	<input type="submit" name="save" value="Save">
</form>
